<?php 
namespace app\authorization\libs;
use app\authorization\libs\Jwt;
/**
 * 接口验证类
 */
class InterfaceSignatureVerification 
{
	/**
	 * 授权token
	 */
	public static function createToken ( $sub = '20200423' , $subpwd , $iss = 'fafd4cf8c648da1aa86338d4a5152294' )
	{
	/*
	 *	'iss'=>'jwt_admin',  //该JWT的签发者
     *  'iat'=>time(),  //签发时间
     *  'exp'=>time()+7200,  //过期时间
     *  'nbf'=>time()+60,  //该时间之前不接收处理该Token
     *  'sub'=>'www.admin.com',  //面向的用户
     *  'jti'=>md5(uniqid('JWT').time())  //该Token唯一标识
     */
		$time = time();
		$payload = [
			'iss' 	=> $iss , //卓远appid
			'iat'	=> $time ,
			'exp' 	=> $time + 7200 ,
			'sub' 	=> $sub ,
			'subpwd'=> $subpwd,
			'jti' 	=> md5( uniqid( 'JWT' ) . $time )
		];
		return Jwt::getToken( $payload );
	}

	/**
	 * 验证token
	 */
	public static function verifyToken ( $token )
	{
		return Jwt::verifyToken( $token );
	}

}